﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Demo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        LeslieXin.SimpleLiveDataFeed.SimpleLiveDataFeed _sldf;

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            _sldf = new LeslieXin.SimpleLiveDataFeed.SimpleLiveDataFeed(null/*可传入NULL，自动生成MSChart*/, "速度", new List<Tuple<string, Color>>()
            {
                new Tuple<string, Color>("速度1",Color.Blue),
                new Tuple<string, Color>("速度2",Color.Green),
                new Tuple<string, Color>("速度3",Color.Pink),
                new Tuple<string, Color>("速度4",Color.Orange),
                new Tuple<string, Color>("速度5",Color.Purple),
            },Color.Red);
            _sldf.DataAcquisition += () =>
            {
                //生成演示用的采集数据
                var r = new Random();
                return new List<Tuple<string, double>>()
                {
                    new Tuple<string, double>("速度1",r.NextDouble()*20+10),
                    new Tuple<string, double>("速度2",r.NextDouble()*40+30),
                    new Tuple<string, double>("速度3",r.NextDouble()*60+50),
                    new Tuple<string, double>("速度4",r.NextDouble()*80+70),
                    new Tuple<string, double>("速度5",r.NextDouble()*100+90),
                };
            };
            panel1.Controls.Add(_sldf.MSChart);//添加自动生成的MSChart
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            //开始
            _sldf?.Start();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            //停止
            _sldf?.Stop();
        }
    }
}
